<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/style.css"/>">

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/script.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/zzsc.js"/>"></script>
</head>
<body>
<style>
     ol,li{
      	  float: left;
     }
</style>

<script type="text/javascript">
   $(function(){
	   
	//打开门诊收费选择挂号窗口
	$("#btn-cy_mzsf").linkbutton({onClick: function(){
		$('#cy-win-ghmzgf').window({
			'title' : "选择挂号",
			'href' : "cy_mzsf_register"
		});
		$("#cy-win-ghmzgf").window("open");
		
	}}); 
	
	//关闭收费管理
	$("#cy_btn_mzsfqx").linkbutton({onClick: function(){
		$('#win-collectfees').window('close');	
								
	}});
	
	//通过onChange计算出应退多少金额
	$("#mzsfPaid").numberbox({onChange:function(n,o){
		var price = $("#cfkyMoney").numberbox('getValue');
		var number = $("#mzsfPaid").numberbox('getValue');
		var ytMoney = $("#mzsfRefundableAmount").numberbox('setValue',number - price);
	}})
	
	
	//收费处理
	$("#cy_btn_ghmzsfcl").linkbutton({onClick: function(){
		var rowmzsf = $("#dzbl_ghmzsf").datagrid('getRows');
		var mzsfPaid = $("#mzsfPaid").numberbox('getValue');
		var Money = $("#cfkyMoney").numberbox('getValue')+'.00';
		var s = $("#ghNo").textbox('getText');
		if(!s){
			$.messager.alert('His六医院','收费项目数据不完整，请核对！','info');
		}else if(mzsfPaid!=Money){
			$.messager.alert('His六医院','实收金额不足，不能继续处理','info');
			
		}else if(mzsfPaid==Money){
		var mzsf = [];
		var sfjl = [];
		
		for(var i = 0;i<rowmzsf.length;i++){
		
			alert(rowmzsf[i].cfkyState)
			mzsf.push(rowmzsf[i].cfkyNo)
			mzsf.push(rowmzsf[i].cfkyState)
			mzsf.push(rowmzsf[i].sfxmState)
		}
		
		$("#cy_mzsfyp_gh").form('submit', {
			url : 'cyHisOutpatientChargeServiceAdd',
			onSubmit : function(param) {
				param.arryp=mzsf;
			},
			success : function(data) {
				$('#mzsfState').combobox('setValue', '已处理');
				var json = eval("(" + data + ")");
				
				rowmzsf = $("#dzbl_ghmzsf").datagrid('getRows');
				
				//多行删除已结算的数据
				for(var i=rowmzsf.length-1;i>=0;i--){				
					var cynn = $("#dzbl_ghmzsf").datagrid('getRowIndex',rowmzsf[i]);
							   $('#dzbl_ghmzsf').datagrid('deleteRow',
								 cynn);				   	   
				}				
				
				$.messager.alert("提示", json.reason);
				$.messager.confirm('His六医院', '你好，请问是否打印门诊收费单？', function(r){
					if (r){
						$("#cy-win-mzsf-dyyl").window("open");
					}
				})
			}
		});	
		
		}
	}})
	
	//打开退费窗口
	$("#btn_head_refund").linkbutton({onClick: function(){
		$('#win-refund').window({
			'title' : "退费管理",
			'href' : "cy_his_mztf"
		});
		$("#win-refund").window("open");
		
	}});
	
	//打开电子病历浏览表单窗口
	$("#cy_btn_mzsfdyyl").linkbutton({onClick: function(){
		var dzcfno = $("#cydzcfNo").textbox('getValue');
		var ghno = $("#ghNo").textbox('getValue');
		var mzsfdate = $("#mzsfDate").datebox('getValue');
		var cfkymoney = $("#cfkyMoney").numberbox('getValue');
		var name = $("#brName").textbox('getValue');
		var mzsfpaid = $("#mzsfPaid").numberbox('getValue');
		var mzsfrefundableAmount = $("#mzsfRefundableAmount").numberbox('getValue');
		$('#cy-win-mzsf-dyyl').window({
			'title' : "浏览表单",
			'href' : "cy_mzsfprint?dzcfNo="+dzcfno+"&ghNo="+ghno
			+"&mzsfDate="+mzsfdate+"&mzsfAmounReceivable="+cfkymoney+"&brName="+name
			+"&mzsfPaid="+mzsfpaid+"&mzsfRefundableAmount="+mzsfrefundableAmount
		});
		$("#cy-win-mzsf-dyyl").window("open");
		
	}}); 
   })
   
   //局部打印
	function printHtml(html){ 
	    var bodyHtml = document.body.innerHTML;
	    document.body.innerHTML=html;
	    window.print();
	    document.body.innerHTML=bodyHtml;		    
	}
	//调用局部打印方法
	function mzsfonprint(){
		var html = $("#mzsfprintArea").html();
		$("#cy-win-register_print").window("close");
		printHtml(html);
		location.reload(true);
	}
</script>
<div class="easyui-layout" data-options="fit:true">
			<div data-options="region:'north',height:'35px',border:false">
			    <div class="btn-add">
			    	<a id="" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-add',width: '80px'">新建</a> 
			    		&nbsp;
			    		
			    	<a id="btn_head_refund" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-open',width: '80px'">退费</a> 	
			    		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			    			
			    	<a style="position: relative;left: 140px;" id="cy_btn_ghmzsfcl" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-handle',width: '80px'">处理</a>
			    		&nbsp;
			    		
			    	<a style="position: relative;left: 270px;" id="cy_btn_mzsfdyyl" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-print',width: '80px'">打印</a>	
			    		&nbsp;
			    		
			    	<a style="position: relative;left: 280px;" id="cy_btn_mzsfqx" class="easyui-linkbutton" 
			    		data-options="iconCls:'icon-cancel',width: '80px'">取消</a>
			    				
			    </div>			    
			</div>	
			<div data-options="region:'center'">
				<form id="cy_mzsfyp_gh" method="post">
					<div class="" style="background: rgb(236,243,255);height: 145px;width: 100%">
						<ol style="height:145px;">
						
					      	<li style="margin: 0px; padding: 15px;position: relative;left: 19px;">门诊收费号&nbsp;
					      		<input id="cydzcfNo" readonly="readonly" value="${OutpatientChargeId }" name="dzcfNo" class="easyui-textbox"
								data-options="width: 100">
							</li>
								
							<li style="margin: 0px;padding: 15px;position: relative;left: 125px;">状态&nbsp;
								<select id="mzsfState" readonly="readonly" name="mzsfState" class="easyui-combobox"  
					     		data-options="panelHeight: 'auto'" id=""  style="width: 80px;">
								<option value="未处理">未处理</option>
								<option value="已处理">已处理</option>
								</select>
							</li>
								
							<li style="margin: 0px;padding: 15px;position: relative;left: 200px;">收费日期&nbsp;
								<input id="mzsfDate" name="mzsfDate" value="new date" class="easyui-datebox"
								data-options="width: 100"></li>
							</li>
								
							<li style="margin: 0px; padding: 15px;position: relative;right: 478px;top: 35px;">门诊号&nbsp;
					      		<input id="ghNo" readonly="readonly" value="" name="ghNo" class="easyui-textbox"
								data-options="width: 100">
								
								<a id="btn-cy_mzsf" class="easyui-linkbutton" 
				    			data-options="iconCls:'icon-three',plain:true"></a>
							</li>
							
							<li style="margin: 0px; padding: 15px;position: relative;left: 310px;bottom: 20px;">处方号&nbsp;
					      		<input id="dzcfNo" readonly="readonly" value="" name="dzcfNo" class="easyui-textbox"
								data-options="width: 100">
								
								<a id="btn-cy_dzcf" class="easyui-linkbutton" 
				    			data-options="iconCls:'icon-three',plain:true"></a>
							</li>
								
								
							<li style="margin: 0px;padding: 15px;position: relative;left: 335px;bottom: 20px;">病人姓名&nbsp;
								<input id="brName" readonly="readonly" value="" name="brName" class="easyui-textbox"
								data-options="width: 100">
								
							</li>
								
							<li style="margin: 0px; padding: 15px;position: relative;right: 355px;top: 18px;">应收金额&nbsp;
					      		<input id="cfkyMoney" readonly="readonly" value="0.00" name="mzsfAmounReceivable" class="easyui-numberbox"
								data-options="width: 100,height:36,precision:2">
								
							</li>
							
							<li style="margin: 0px; padding: 15px;position: relative;right: 270px;top: 18px;">实收金额&nbsp;
					      		<input id="mzsfPaid" value="0.00" name="mzsfPaid" class="easyui-numberbox"
								data-options="width: 100,height:36,precision:2">
								
							</li>
								
								
							<li style="margin: 0px; padding: 15px;position: relative;right: -538px;top: -48px;">应退金额&nbsp;
					      		<input id="mzsfRefundableAmount" style="font-size: 15px;color: red" value="0.00" name="mzsfRefundableAmount" class="easyui-numberbox"
								data-options="width: 100,height:36,precision:2">
								
							</li>	
																																															
					     </ol>
					</div>	
					<div id="tt" class="easyui-tabs" data-options="border:false,panelHeight:'auto'" style="width: 100%;overflow: hidden;">
	
						<div id="tab_wsf" title="未收费" style="width: 100%;overflow: hidden;height: 300px">
						
							<div style="overflow: hidden;height: 215px">
								<table  id="dzbl_ghmzsf" class="easyui-datagrid" 
									data-options="
											iconCls: 'icon-edit',							                
											width: '100%',
											height: '215px',
											rownumbers: true,
											pagination: true,
											border: false,
											pageSize: 5,
											pageList: [5, 10, 15, 20],
										
										">
									<thead>
										<tr>
											<th
												data-options="field:'cfkyNo',width:'20%',editor:'textbox'">收费编号</th>
											<th
												data-options="field:'cfkyType',width:'15%',editor:'textbox'">收费类型</th>
											<!-- <th
												data-options="field:'cfkyType',width:'20%',editor:'textbox'">收费项目</th>
											<th
												data-options="field:'cpName',width:'15%',editor:'textbox'">收费日期</th> -->
											<th
												data-options="field:'cfkyMoney',width:'10%',editor:'textbox'">金额</th>
											<th
												data-options="field:'cfkyState',width:'20%',editor:'textbox'">状态</th>	
											</tr>	
										</tr>
									  </thead>
								 </table>
							 </div>											
						</div>	
						<div id="tabs_ysf" title="已收费" style="width: 100%;overflow: hidden;height: 300px">
						
							<div style="overflow: hidden;height: 215px">
								<table  id="dzbl_yighmzsf" class="easyui-datagrid" 
									data-options="
											iconCls: 'icon-edit',							                
											width: '100%',
											height: '215px',
											rownumbers: true,
											pagination: true,
											border: false,
											pageSize: 5,
											pageList: [5, 10, 15, 20],
										
										">
									<thead>
										<tr>
											<th
												data-options="field:'cfkyNo',width:'20%',editor:'textbox'">收费编号</th>
											<th
												data-options="field:'cfkyType',width:'15%',editor:'textbox'">收费类型</th>
											<!-- <th
												data-options="field:'cfkyType',width:'20%',editor:'textbox'">收费项目</th>
											<th
												data-options="field:'cpName',width:'15%',editor:'textbox'">收费日期</th> -->
											<th
												data-options="field:'cfkyMoney',width:'10%',editor:'textbox'">金额</th>
											<th
												data-options="field:'cfkyState',width:'20%',editor:'textbox'">状态</th>	
											</tr>	
										</tr>
									  </thead>
								 </table>
							 </div>											
						</div>											
				  </div>     												
			</form>
		</div>
	</div>
	
	<!-- 门诊收费选择挂号窗口 -->
	<div id="cy-win-ghmzgf" class="easyui-window" title="选择挂号"
		data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-registered',closed: true"
		style="width: 800px; height: 280px; padding: 5px;">
	</div>
	
	<!-- 打开门诊退费窗口 -->
	<div id="win-refund" class="easyui-window" title="退费管理"
		data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-registered',closed: true"
		style="width: 800px; height: 475px; padding: 5px;">
	</div>
	
	<!-- 门诊收费的浏览表单 -->
	<div id="cy-win-mzsf-dyyl" class="easyui-window" title="浏览表单"
		data-options="tools:'#dyyl',collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-registered',closed: true"
		style="width: 800px; height: 500px; padding: 5px;">

	</div>
	
	<div id="dyyl">
    
	    <a href="#" title="打印" id='plan-printyl' class="icon-print" style="cursor: pointer;" onclick="mzsfonprint()"></a>

    </div>	
</body>
</html>